﻿@using System.Web.Security
@model IEnumerable<MembershipUser>
@{
    ViewBag.Title = "Manage Users";          
}
<script type="text/javascript">
    $(document).ready(function ()
    {
        $('a.delete').click(function (e)
        {
            var user = $(this).parent().attr('data-user');
            if (!confirm('Are you sure you want to delete ' + user + '?'))
                e.preventDefault();
        });
    });
</script>
<p>Manage the existing users in the application below.</p>
<p>@Html.ActionLink("Create New User", "NewUser")</p>
<table id="users">
    <thead>
        <tr>
            <th>User Name</th>
            <th>Email Address</th>
            <th>Last Login</th>
            <th></th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        @foreach (var user in Model.OrderBy(u => u.UserName))
        {
            <tr>
                <td>@user.UserName</td>
                <td>@user.Email</td>
                <td>@user.LastLoginDate</td>
                <td>@Html.ActionLink("Edit", "EditProfile", "Account", new { id = user.UserName }, new { @class = "edit" })</td>
                <td data-user="@user.UserName">@Html.ActionLink("Delete", "Delete", "Admin", new { id = user.UserName }, new { @class = "delete" })</td>
            </tr>
        }
    </tbody>
</table>
